package com.qigao.mall.web.controller;

import com.qigao.mall.api.ShopEmpService;
import com.qigao.mall.commons.dto.ShopEmpResultDto;
import com.qigao.mall.commons.enums.Result;
import com.qigao.mall.commons.enums.ResultCode;
import com.qigao.mall.web.controller.app.merchant.ShopEmpController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author luiz
 * @Title: AbstractUserController
 * @ProjectName iot
 * @Description: TODO
 * @date 2019-04-17 17:12
 */
@Component
public abstract class AbstractShopEmpController {
    private static final Logger logger = LoggerFactory.getLogger(ShopEmpController.class);
    @Resource
    private ShopEmpService shopEmpService;

    //4.按照员工号查询店铺列表
    @GetMapping("/findShopByUserNo/{userNo}")
    public Result findShopByUserNo(@PathVariable("userNo")String userNo){
        try{
            List<ShopEmpResultDto> shopEmpResultDtos=shopEmpService.findByEmpNo(userNo);
            if(shopEmpResultDtos==null || shopEmpResultDtos.size()<=0){
                return Result.newError(ResultCode.COMMON_DATA_NOT_EXISTS);
            }
            return Result.newSuccess(shopEmpResultDtos);
        }catch (Exception e){
            logger.error("按照员工号查询店铺列表发生异常:{}",e);
            return Result.newError(ResultCode.FAIL);
        }
    }


}
